package c1764;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

/**
 * 连续和
 * 二分法算法：前提是f(q)=p+。。。。+q对q是单调不减的，
 * 复杂度:O(NlogN)
 * N<1e7
 */
public class F03NlogN {

    public static void main(String[] args) {//O(n^2)
        long start = System.currentTimeMillis();
        long n = 1500000;
        for (int p = 1; p <= n / 2; p++) {

            long left = p + 1, right = n;
            while (left <= right) {
                long q = (left + right) / 2;
                long s = (q - p + 1) * (p + q) / 2;
                if (s == n) {
                    System.out.println(p + " " + q);
                    break;
                } else if (s > n) {
                    right = q - 1;
                } else {
                    left = q + 1;
                }
            }
        }
        long end = System.currentTimeMillis();
        System.out.println((end - start) / 1000.0 + " second(s).");
    }


    static Scanner cin = null;

    static {
        try {
            cin = new Scanner(new FileReader(new File("test.in")));
        } catch (FileNotFoundException e) {
            cin = new Scanner(System.in);
        }
    }
}